package com.working.libbase.model

import android.graphics.Bitmap
import android.os.Parcel
import android.os.Parcelable
import com.squareup.moshi.JsonClass

@JsonClass(generateAdapter = true)
data class BackUpModel(
    val title: CharSequence?,
    val url: String?,
    val thumbnail: Bitmap?,
    val anchor: Int
) : Parcelable {
    constructor(parcel: Parcel) : this(
        parcel.readString(),
        parcel.readString(),
        parcel.readParcelable(Bitmap::class.java.classLoader),
        parcel.readInt()
    ) {
    }

    override fun writeToParcel(parcel: Parcel, flags: Int) {
        parcel.writeString(title?.toString())
        parcel.writeString(url)
        parcel.writeParcelable(thumbnail, flags)
        parcel.writeInt(anchor)
    }

    override fun describeContents(): Int {
        return 0
    }

    companion object CREATOR : Parcelable.Creator<BackUpModel> {
        override fun createFromParcel(parcel: Parcel): BackUpModel {
            return BackUpModel(parcel)
        }

        override fun newArray(size: Int): Array<BackUpModel?> {
            return arrayOfNulls(size)
        }
    }
}

data class BackupChangeEvent(val backUpModel: BackUpModel?, val operator: Int)